//
//  DCTaskDetailHeaderView.m
//  JiuyaoMotorcade
//
//  Created by 大橙子 on 2018/11/29.
//  Copyright © 2018 Tomous. All rights reserved.
//

#import "DCTaskDetailHeaderView.h"
@interface DCTaskDetailHeaderView ()
@property (nonatomic,strong) UIView *firstView;
@property (nonatomic,strong) DCImageAndTextLabel *startView;
@property (nonatomic,strong) DCImageAndTextLabel *endView;
@property (nonatomic,strong) UIView *line;

@property (nonatomic,strong) UIView *secondView;
@property (nonatomic,strong) DCLabelAndTextLabel *receiveNameLabel;
@property (nonatomic,strong) DCLabelAndTextLabel *receivePhoneLabel;
@property (nonatomic,strong) DCLabelAndTextLabel *receiveTimeLabel;
@end
@implementation DCTaskDetailHeaderView
-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setUpUI];
    }
    return self;
}
-(void)setUpUI {
    self.firstView = [[UIView alloc]init];
    self.firstView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.firstView];
    
    self.startView = [[DCImageAndTextLabel alloc]init];
    self.startView.imageView.image = IMAGENAME(@"起点");
    [self.firstView addSubview:self.startView];
    
    self.line = [[UIView alloc]init];
    self.line.backgroundColor = [UIColor lightGrayColor];
    [self.firstView addSubview:self.line];
    
    self.endView = [[DCImageAndTextLabel alloc]init];
    self.endView.imageView.image = IMAGENAME(@"终点");
    [self.firstView addSubview:self.endView];
    
    self.secondView = [[UIView alloc]init];
    self.secondView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.secondView];
    
    self.receiveNameLabel = [[DCLabelAndTextLabel alloc]init];
    self.receiveNameLabel.titleLabel.text = @"收货人";
    self.receiveNameLabel.textField.enabled = NO;
    [self.secondView addSubview:self.receiveNameLabel];
    
    self.receivePhoneLabel = [[DCLabelAndTextLabel alloc]init];
    self.receivePhoneLabel.titleLabel.text = @"联系方式";
    self.receivePhoneLabel.textField.enabled = NO;
    [self.secondView addSubview:self.receivePhoneLabel];
    
    self.receiveTimeLabel = [[DCLabelAndTextLabel alloc]init];
    self.receiveTimeLabel.titleLabel.text = @"要求到货时间";
    self.receiveTimeLabel.textField.enabled = NO;
    self.receiveTimeLabel.line.hidden = YES;
    [self.secondView addSubview:self.receiveTimeLabel];
}
-(void)layoutSubviews {
    [super layoutSubviews];
    self.firstView.frame = CGRectMake(0, 2, self.width, 80);
    self.startView.frame = CGRectMake(10, 0, self.firstView.width-10, 40);
    self.line.frame = CGRectMake(30, self.startView.bottom, self.firstView.width - 35 , 0.5);
    self.endView.frame = CGRectMake(10,self.startView.bottom, self.firstView.width-10, 40);
    
    self.secondView.frame = CGRectMake(0, self.firstView.bottom, self.width, 120);
    self.receiveNameLabel.frame = CGRectMake(10, 0, self.secondView.width-20, self.secondView.height/3);
    self.receivePhoneLabel.frame = CGRectMake(10, self.receiveNameLabel.bottom, self.receiveNameLabel.width, self.secondView.height/3);
    self.receiveTimeLabel.frame = CGRectMake(10, self.receivePhoneLabel.bottom, self.secondView.width-20, self.secondView.height/3);
}
-(void)setModel:(DCTaskDetailOddArray *)model {
    _model = model;
    self.startView.textLabel.text = Str_IsEmpty(model.startAddress)?@"":model.startAddress;
    self.endView.textLabel.text = [NSString stringWithFormat:@"%@%@",model.endCity,model.endAddress];
    
    NSDictionary *dict = model.receiverArray.count?model.receiverArray[0]:nil;
    self.receiveNameLabel.textField.text = dict[@"name"];
    self.receivePhoneLabel.textField.text = dict[@"phoneNumber"];
    self.receiveTimeLabel.textField.text = model.endDate;
    
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
